package com.lgh.hotel.controller;

import com.lgh.hotel.common.aop.LogAnnotation;
import com.lgh.hotel.dao.pojo.Roles;
import com.lgh.hotel.service.RolesService;
import com.lgh.hotel.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "权限模块")
@RestController
@RequestMapping("roles")
public class RolesController {

    @Autowired
    RolesService rolesService;

    @LogAnnotation
    @ApiOperation("获取所有权限类型")
    @GetMapping
    public Result roles(){
        return rolesService.findRolesAll();
    }

    @LogAnnotation
    @ApiOperation("增加权限名称")
    @GetMapping("/add/{name}")
    public Result addName(@PathVariable("name")String name){
        return rolesService.addRole(name);
    }

    @LogAnnotation
    @ApiOperation("删除单个权限名称")
    @DeleteMapping("/deleteRoles")
    public Result deleteRoles(@RequestBody Roles roles){
        return rolesService.deleteRoles(roles.getId());
    }


    @LogAnnotation
    @ApiOperation("更改权限名称")
    @PutMapping("/updateRoles")
    public Result updateRoles(@RequestBody Roles roles){
        return rolesService.updateRoles(roles);
    }



}

